package git.matrix.service.impl;

import git.matrix.mapper.UserMapper;
import git.matrix.pojo.Page;
import git.matrix.pojo.User;
import git.matrix.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userService")
@Repository
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;


    /**
     * 登录
     * @param userName
     * @param password
     * @return
     */
    @Override
    public User getLogin(String userName, String password) {
        return userMapper.getLogin(userName,password);
    }

    @Override
    public List<User> getAllUser() {
        return userMapper.getAllUser();
    }

    @Override
    public List<User> getUserByPage(String userName, int userRoleId, Page page) {
        // TODO Auto-generated method stub
        int totalCount = userMapper.getUserByNRCount(userName, userRoleId);//总数
        page.setTotalCount(totalCount);
        int Current = (page.getCurrentPage()-1)*page.getSize();//z最新一夜
        return userMapper.getUserListByPage(userName, userRoleId,Current,page.getSize());

    }

    @Override
    public User getUserId(int id) {
        return userMapper.getUserId(id);
    }

    @Override
    public int addUser(User user) {
        return 0;
    }

    @Override
    public int updateUser(User user) {
        return 0;
    }

    @Override
    public int deleteUser(int id) {
        return 0;
    }

    @Override
    public List<User> getUserRole() {
        return userMapper.getUserRole();
    }
}
